﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;


namespace Sublimation
{
    public class HighScore
    {
        protected List<int> scores;
        public List<int> Score
        {
            get { 
                scores.Sort() ;
                return scores;
            }
            set { scores = value; }
        }
        protected int currentScore;
        public int CurrentScore{
            get { return currentScore; }
            set{currentScore = value;}
        }

        protected int smallCreepDead;
        public int SmallCreepDead
        {
            get { return smallCreepDead; }
            set { smallCreepDead = value; }
        }

        protected int bigCreepDead;
        public int BigCreepDead
        {
            get { return bigCreepDead; }
            set { bigCreepDead = value; }
        }

        protected int whipGallDead;
        public int WhipGallDead
        {
            get { return whipGallDead; }
            set { whipGallDead = value; }
        }

        protected int bossDead;
        public int BossDead
        {
            get { return bossDead; }
            set { bossDead = value; }
        }

        protected int kamikazeDead;
        public int KamikazeDead
        {
            get { return kamikazeDead; }
            set { kamikazeDead = value; }
        }

        protected int priestDead;
        public int PriestDead
        {
            get { return priestDead; }
            set { priestDead = value; }
        }

        protected int wizardDead;
        public int WizardDead
        {
            get { return wizardDead; }
            set { wizardDead = value; }
        }
       
 

        public void  enemyKilled(EnemyKind kind){
            switch(kind){
                case EnemyKind.BigCreep :
                    bigCreepDead++;
                    break;
                case EnemyKind.Boss:
                    bossDead++;
                    break;
                case EnemyKind.Kamikaze:
                    kamikazeDead++;
                    break;
                case EnemyKind.Priest:
                    priestDead++;
                    break;
                case EnemyKind.SmallCreep:
                    smallCreepDead++;
                    break;
                case EnemyKind.WhipGall:
                    whipGallDead++;
                    break;
                case EnemyKind.Wizard:
                    wizardDead++;
                    break;
            }
        }

        protected DrawableText scoreText;

        public HighScore()
        {
            scoreText = new DrawableText();
            scoreText.Scale = 1.6f;
            scoreText.Color = new Color(Color.DarkOrange, 200);
            scores = new List<int>();
        }

        public void reset() {
            currentScore = 0;
            smallCreepDead = 0;
            bigCreepDead = 0;
            whipGallDead = 0;
            kamikazeDead = 0;
            priestDead = 0;
            wizardDead = 0;
            bossDead = 0;
        }

        public void displayCurrentScore(SpriteBatch spriteBatch,SpriteFont font)
        {
            spriteBatch.Begin();
            spriteBatch.DrawString(font, currentScore.ToString(), new Vector2(530, 450), scoreText.Color, 0, Vector2.Zero, scoreText.Scale*0.8f, SpriteEffects.None, 0.0f);
            spriteBatch.DrawString(font, currentScore.ToString(), new Vector2(500, 317), scoreText.Color, 0 + MathHelper.Pi, Vector2.Zero, scoreText.Scale*0.8f, SpriteEffects.None, 0.0f);

            spriteBatch.DrawString(font, bossDead.ToString(), new Vector2(380, 495), scoreText.Color, 0 , Vector2.Zero, scoreText.Scale * 0.8f, SpriteEffects.None, 0.0f);
            spriteBatch.DrawString(font, bossDead.ToString(), new Vector2(625, 280), scoreText.Color, 0 + MathHelper.Pi, Vector2.Zero, scoreText.Scale * 0.8f, SpriteEffects.None, 0.0f);

            spriteBatch.DrawString(font, wizardDead.ToString(), new Vector2(380, 535), scoreText.Color, 0 , Vector2.Zero, scoreText.Scale * 0.8f, SpriteEffects.None, 0.0f);
            spriteBatch.DrawString(font, wizardDead.ToString(), new Vector2(625, 240), scoreText.Color, 0 + MathHelper.Pi, Vector2.Zero, scoreText.Scale * 0.8f, SpriteEffects.None, 0.0f);

            spriteBatch.DrawString(font, priestDead.ToString(), new Vector2(380, 575), scoreText.Color, 0 , Vector2.Zero, scoreText.Scale * 0.8f, SpriteEffects.None, 0.0f);
            spriteBatch.DrawString(font, priestDead.ToString(), new Vector2(625, 202), scoreText.Color, 0 + MathHelper.Pi, Vector2.Zero, scoreText.Scale * 0.8f, SpriteEffects.None, 0.0f);

            spriteBatch.DrawString(font, bigCreepDead.ToString(), new Vector2(380, 615), scoreText.Color, 0 , Vector2.Zero, scoreText.Scale * 0.8f, SpriteEffects.None, 0.0f);
            spriteBatch.DrawString(font, bigCreepDead.ToString(), new Vector2(625, 165), scoreText.Color, 0 + MathHelper.Pi, Vector2.Zero, scoreText.Scale * 0.8f, SpriteEffects.None, 0.0f);

            spriteBatch.DrawString(font, whipGallDead.ToString(), new Vector2(625, 495), scoreText.Color, 0 , Vector2.Zero, scoreText.Scale * 0.8f, SpriteEffects.None, 0.0f);
            spriteBatch.DrawString(font, whipGallDead.ToString(), new Vector2(380, 280), scoreText.Color, 0 + MathHelper.Pi, Vector2.Zero, scoreText.Scale * 0.8f, SpriteEffects.None, 0.0f);

            spriteBatch.DrawString(font, smallCreepDead.ToString(), new Vector2(625, 535), scoreText.Color, 0 , Vector2.Zero, scoreText.Scale * 0.8f, SpriteEffects.None, 0.0f);
            spriteBatch.DrawString(font, smallCreepDead.ToString(), new Vector2(380, 240), scoreText.Color, 0 + MathHelper.Pi, Vector2.Zero, scoreText.Scale * 0.8f, SpriteEffects.None, 0.0f);

            spriteBatch.DrawString(font, kamikazeDead.ToString(), new Vector2(625, 575), scoreText.Color, 0 , Vector2.Zero, scoreText.Scale * 0.8f, SpriteEffects.None, 0.0f);
            spriteBatch.DrawString(font, kamikazeDead.ToString(), new Vector2(380, 202), scoreText.Color, 0 + MathHelper.Pi, Vector2.Zero, scoreText.Scale * 0.8f, SpriteEffects.None, 0.0f);

            spriteBatch.End();  
        }

        public void displayHighScores(SpriteBatch spriteBatch, SpriteFont font)
        {
            for (int i = 0; i < 5 && i<scores.Count; i++)
            {
                spriteBatch.Begin();
                spriteBatch.DrawString(font, Score[scores.Count-1-i].ToString(), new Vector2(600, 495+28*i), scoreText.Color, 0, Vector2.Zero, scoreText.Scale * 0.6f, SpriteEffects.None, 0.0f);
                spriteBatch.DrawString(font, Score[scores.Count - 1 - i].ToString(), new Vector2(410, 280-28*i), scoreText.Color, 0 + MathHelper.Pi, Vector2.Zero, scoreText.Scale * 0.6f, SpriteEffects.None, 0.0f);
                spriteBatch.End();
            }
        }
    }
}
